/*
 * @Description: 
 * @Author: Leequik
 * @Date: 2024-02-09 14:00:00
 * @LastEditTime: 2025-07-07 10:56:17
 * @LastEditors: Leequik
 */

import './bootstrap';
//import router from './router.ts';

import router from './routers';

import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'

//全局引入axios
import axios from 'axios';

import { createApp } from 'vue';

//全局引入bootstrap
import 'bootstrap/dist/css/bootstrap.min.css';

//安装pinia  npm install i pinia  引入 
import { createPinia } from 'pinia'
//引入emitter,自定义事件仓库
import emitter from './views/test/utils/emitter'


import App from './App.vue';

//创建pinia (最好在.App.vue文件后引入创建的pinia实例)
const pinia = createPinia()

const app = createApp(App);
//使用
app.use(pinia)

//全局挂载axios
app.config.globalProperties.$axios = axios; 
axios.defaults.baseURL = ' http://localhost:5173';

//跨域请求的处理
/*
axios.prototype.$axios = axios;
axios.defaults.baseURL = '/api';


app.use(async (ctx,next)=>{
    ctx.set('Access-Control-Allow-Origin', '*');
    ctx.set('Access-Control-Allow-Headers', 'Content-Type,Content-Length, Authorization, Accept,X-Requested-With');
    ctx.set('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE,OPTIONS');
    if (ctx.method == 'OPTIONS') {
        ctx.body = 200;
    }else{
        await next();
    }
})
 */



import ExampleComponent from './components/ExampleComponent.vue';
app.component('example-component', ExampleComponent);

/**
 * The following block of code may be used to automatically register your
 * Vue components. It will recursively scan this directory for the Vue
 * components and automatically register them with their "basename".
 *
 * Eg. ./components/ExampleComponent.vue -> <example-component></example-component>
 */

// Object.entries(import.meta.glob('./**/*.vue', { eager: true })).forEach(([path, definition]) => {
//     app.component(path.split('/').pop().replace(/\.\w+$/, ''), definition.default);
// });

/**
 * Finally, we will attach the application instance to a HTML element with
 * an "id" attribute of "app". This element is included with the "auth"
 * scaffolding. Otherwise, you will need to add an element yourself.
 */
app.use(router).use(ElementPlus).mount('#app');
